<{include file = '../include/user_header.html'}>

<ul class="list-group list-group-flush">
	<{foreach from = $comments item = $comment key = $key}>
	<li class="list-group-item">
		<div class="media pt-3">
			<a href="<{url('user','index',$comment.user.uid)}>"><img src="<{$comment.user.avatar}>" class="mr-3 rounded-circle" style="width:50px;"></a>
			<div class="media-body">
				<h6 color="<{$comment.user.group.font_color}>">
					<{$comment.user.username}>
				</h6>
				<p>
					<span class="badge text-white" bgcolor="<{$comment.user.group.color}>">
						<{$comment.user.group.name}>
					</span>
					<span class="float-right text-muted"><{timeFormat($comment.time)}></span>
				</p>
				
				<p>回复了 《<a href="<{url('thread','index',$comment.tid,0,0,1)}>"><{$comment.thread.title}></a>》：<br><span class="content"><{content($comment.content)}></span></p>
				
				<ul class="nav float-right comment-action-list">
					<li class="nav-item"><a class="nav-link" href="#" data-toggle="modal" data-target="#comment-delete-<{$comment.cid}>">删除</a></li>
					<li class="nav-item"><a class="nav-link copy-comment" href="javascript:HuajiBBS.copy('<{nl2str($comment.content)}>').tips('复制成功','success');">复制全文</a></li>
				</ul>
				
				<!-- 删除弹窗 -->
				<div class="modal fade" id="comment-delete-<{$comment.cid}>">
					<div class="modal-dialog">
						<div class="modal-content">
							<div class="modal-header">
								<h5 class="modal-title">你确定要删除此评论吗？</h5>
								<button type="button" class="close" data-dismiss="modal">&times;</button>
							</div>
							<div class="modal-body">
								<{quote_comment($comment)}>
								删除后将永远无法恢复，如果你坚持删除，请点击【确定】，否则请点击【取消】。
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
								<button type="button" class="btn btn-primary comment-delete" data-id="<{$comment.cid}>">确定</button>
							</div>
						</div>
					</div>
				</div>
				<!-- 删除弹窗 -->
			</div>
		</div>
	</li>
	<{foreachelse}>
	<p class="text-center text-muted mt-5 mb-5">空空如也～</p>
	<{/foreach}>
</ul>
<div class="pt-3">
	<{pagination($user.comments,30,$p_1,url('user','comments',$p_0,'{{page}}'))}>
</div>

<script>
$('.comment-delete').click(function() {
	var cid = $(this).data('id');
	HuajiBBS.request("<{url('thread','delete_comment_ajax','" + cid + "')}>");
});
</script>


<{include file = '../include/user_footer.html'}>